﻿@model Message
@{
    ViewBag.Title = T("Reply");
}
<script type="text/javascript">
	$("form#topicReplyForm").submit(preventMultipleSubmit);
	
	function toggleEmail()
	{
		if ($("#notify").is(":checked"))
		{
			$('#email').show().focus();
		}
		else
		{
			$('#email').hide();
		}
	}
	$(document).ready(toggleEmail);
</script>
	
<ul class="path floatContainer">
    <li class="first">@ActionLinkLocalized("Main", "Index", "Home")</li>
	<li>@ActionLinkLocalized("Forums", "List", "Forums")</li>
	<li>@Html.ActionLink(Model.Topic.Forum.Name, "Detail", "Forums", new{forum=Model.Topic.Forum.ShortName}, null)</li>
	<li>@Html.ActionLink(Model.Topic.Title, "Detail", "Topics", new{id=Model.Topic.Id, name=Model.Topic.ShortName,forum=Model.Topic.Forum.ShortName}, null)</li>
</ul>
<h1>@ViewBag.Title</h1>
@Html.ValidationSummary("<h3>" + S("Please check the following errors:") + "</h3>", new Dictionary<string, object>
	{
		{"Body", S("Body must not be blank.")}
		,{"captcha", new Dictionary<ValidationErrorType, string>(){
			{ValidationErrorType.NullOrEmpty, S("Captcha must not be blank.")}
			,{ValidationErrorType.CompareNotMatch, S("Captcha does not match the image value. Please retry.")}}}
		,{"email", new Dictionary<ValidationErrorType, string>(){
			{ValidationErrorType.NullOrEmpty, S("Email must not be blank in order to notify of new posts.")}
			,{ValidationErrorType.Format, S("Email format is not valid.")}}}
	}, null)
@{Html.BeginForm(null, null, this.Model.InReplyOf == null ? null : new{msg=this.Model.InReplyOf.Id}, FormMethod.Post, new{@id="topicReplyForm"});}
@Html.AntiForgeryToken()
<div class="formItem textarea">
	<label for="body">@T("Description")</label>
	@Html.TextArea("body")
	@Html.Partial("EditorScripts", CreateViewData(new{Name="body"}))
</div>
@Html.Captcha(S("Type the text shown in the image"))
@if (this.Config.Notifications.Subscription.IsDefined)
{
	<div class="formItem floatContainer">
		<div class="checkbox">
			@Html.CheckBox("notify", new{onclick = "toggleEmail();"})
			<label for="notify">@T("Notify me of new posts on this thread via email")</label>
			@(this.User.Email == null ? Html.TextBox("email", null, new{@class="notifyEmail", @style="display:none;"}) : MvcHtmlString.Empty)
		</div>
	</div>
}
else
{
	@Html.Hidden("notify", false)
}
<div class="formItem buttons">
	<input type="submit" value="@T("Send")" />
</div>
@{Html.EndForm();}
@if (this.Model.InReplyOf != null)
{
<script type="text/javascript">
	$(document).ready(function ()
	{
		if ($.trim($('#body').val()) == "")
		{
			$('#body').val('<p>#@(this.Model.InReplyOf.Id):&nbsp;</p>');
		}
	});
</script>
}